package com.zjitc.redis;

import com.alibaba.fastjson.JSON;
import com.zjitc.domain.User;
import redis.clients.jedis.Jedis;

public class MyRedis {
    //连接本地的 Redis 服务
    public static Jedis jedis = new Jedis("localhost");
    public static void main(String[] args) {

        System.out.println("Connection to server sucessfully");
        //查看服务是否运行
        System.out.println("Server is running: "+jedis.ping());
        /*以下测试*/
       // testString();
       /* User user = new User();
        user.setAge(10);
        user.setId(5);
        user.setPassword("123456");
        user.setUsername("小三");
        setObject(user);*/
       User u = getObject("小三");
       System.out.println(u);
    }
    public  static void testString(){
        System.out.println(jedis.get("mykey"));
        jedis.set("javakey","newkey");
        System.out.println(jedis.get("javakey"));
    }

    /**
     * 存储对象
     * @param user
     */
    public static void setObject(User user){
      /*  RedisSerializer<Object> serializer = new JdkSerializationRedisSerializer();
        System.out.println("key = ***"+serializer.serialize(key).toString());
        System.out.println("value = ***"+serializer.serialize(value).toString());*/
    }

    /**
     * 获得对象
     * @param key
     * @return
     */
    public static User getObject(String key){
        return null;
    }


}
